package cn.com.twoke.game.client.games.framework.system;

import cn.com.twoke.game.client.games.framework.component.RenderComponent;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

public class RenderSystem implements RenderComponent {
	public List<RenderComponent> renderComponents = new ArrayList<RenderComponent>();
	
	public void add(RenderComponent component) {
		renderComponents.add(component);
	}

	public void remove(Class<? extends RenderComponent> renderComponentClass) {
		renderComponents.removeIf(item -> renderComponentClass.isInstance(item));
	}
	
	@Override
	public void render(Graphics2D g) {
		renderComponents.forEach(comp -> comp.render(g));
	}

	@Override
	public void show() {
		renderComponents.forEach(RenderComponent::show);
	}

	@Override
	public void hide() {
		renderComponents.forEach(RenderComponent::hide);
	}

}
